package cn.fl.audit.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.comm.facade.syssms.api.ISmsAddApiService;
import cmm.comm.facade.syssms.dto.SmsSendParamDTO;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.api.ISysOrgApiService;
import cmm.user.facade.system.api.ISysUsrApiService;
import cmm.user.facade.system.dto.SysOrgDTO;
import cmm.user.facade.system.dto.SysUsrDTO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.*;
import cn.cmm.cache.framework.constant.CacheConstant;
import cn.cmm.cache.framework.service.ICacheService;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.audit.condition.AudStandingBookQueryCondition;
import cn.fl.audit.constant.AudStandingBookConstant;
import cn.fl.audit.service.IAudStandingBookService;
import cn.fl.audit.vo.AudRejectOpinionVO;
import cn.fl.audit.vo.AudStandingBookVO;
import cn.fl.audit.vo.RevRecVO;
import cn.fl.capital.constant.CapPayInfoConstant;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.commons.enums.ResultCodeEnum;
import cn.fl.commons.result.ResponseData;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.customer.vo.CstAssInfoVO;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.customer.vo.CstExtInfoVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.preloan.IAuditStandingBookService;
import cn.fl.preloan.IPrjBscInfoApiService;
import cn.fl.preloan.IPrjBscInfoJcApiService;
import cn.fl.preloan.condition.AudStaBookForPrjQueryCondition;
import cn.fl.preloan.condition.AuditStandingBookQueryCondition;
import cn.fl.preloan.constants.AuditConstans;
import cn.fl.preloan.dto.RevRecDTO;
import cn.fl.preloan.dto.audit.*;
import cn.fl.preloan.dto.insurance.PageResponse;
import cn.fl.product.service.IPrdBscInfoService;
import cn.fl.product.service.IPrdCarInfoService;
import cn.fl.product.service.IPrdTkInfoService;
import cn.fl.project.condition.PrjBscInfoQueryCondition;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.service.IPrjAuditFlowService;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.service.IPrjPrdBscInfoService;
import cn.fl.project.service.IVehicleStyleService;
import cn.fl.project.vo.PrjBscInfoVO;
import cn.fl.project.vo.PrjCstBscInfoVO;
import cn.fl.project.vo.PrjPrdBscInfoVO;
import cn.fl.project.vo.PrjPrdParamConfigVO;
import cn.fl.ref.fribaseinfo.service.IFriBaseInfoService;
import cn.fl.ref.fribaseinfo.vo.FriBaseInfoVO;
import cn.fl.system.constant.SysLogConstant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.carloan.facade.carloan.api.IOdrQuatPrpsApiService;
import fl.carloan.facade.carloan.condition.OdrQuatPrpsQC;
import fl.carloan.facade.carloan.dto.OdrQuatPrpsDTO;
import fl.constant.facade.framework.constant.SystemConstant;
import fl.customer.facade.customer.api.ICustomerQueryApiService;
import fl.flow.facade.flow.api.IFlowQueryApiService;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import fl.ref.fribaseinfo.condition.FriBaseInfoQueryCondition;
import fl.ref.fribaseinfo.constant.FriBaseInfoConstant;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @Description: 信审台账信息表 控制层
 */
@Controller
@RequestMapping("/audit/audStandingBook")
public class AudStandingBookController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(AudStandingBookController.class);

	/**
	 * AudStandingBook 服务层BEAN
	 */
	@Autowired
	private IAudStandingBookService audStandingBookService;
	
	/**
	 * 用户信息服务
	 */
	@Autowired
	private ISysUsrApiService sysUsrApiService;

	@Autowired
	private IFlowQueryApiService flowQueryApiService;

	@Autowired
	private ISysOrgApiService sysOrgApiService;

	@Autowired
	private IFriBaseInfoService friBaseInfoService;

	/**
	 * 客户信息查询服务
	 */
	@Autowired
	private ICustomerQueryApiService customerQueryApiService;
	
	@Autowired
	private IPrjAuditFlowService prjAuditFlowService;
	
	/**
	 * 客户基础信息服务
	 */
	@Autowired
	private ICstBscInfoService cstBscInfoService;
	
	/**
	 * 项目产品服务
	 */
	@Autowired
	private IPrjPrdBscInfoService prjPrdBscInfoService;
	
	/**
	 * 卡车子产品服务
	 */
	@Autowired
	private IPrdTkInfoService prdTkInfoService;

	/**
	 * 客车/专车/乘用车 子产品服务
	 */
	@Autowired
	private IPrdCarInfoService prdCarInfoService;
	
	/**
	 * 产品服务
	 */
	@Autowired
	private IPrdBscInfoService prdBscscInfoService;
	/**
	 * 车型库产品
	 */
	@Autowired
	private IVehicleStyleService vehicleStyleService;
	 @Autowired
	private ISysDictionaryApiService sysDictionaryApiService ;
	 
	 @Autowired
	 private IOdrQuatPrpsApiService odrQuatPrpsApiService;

	 @Autowired
	 private IAuditStandingBookService auditStandingBookService;

	@Autowired
	private IPrjBscInfoService prjBscInfoService;

	/**
	 * 短信接口
	 */
	@Autowired
	private ISmsAddApiService smsAddApiService;

	@Autowired
	private ICacheService cacheService;

	@Autowired
	private IPrjBscInfoJcApiService prjBscInfoJcApiService;

	//************************************************信审基础台账********************************************/
	
	/** 到信审基础台账列表页面 */
	@RequestMapping(value = "/toAudBscBookListPage.do", method = { RequestMethod.GET})
	public ModelAndView toAudBscBookListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("audit/audBscBook/audBscBookList");
		//查询审批类型
		List<SysDictionaryDTO> SCHR6List = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),DictionaryConstant.RC_CP_MOD_EXT_INFO_SCHR6);
		//List<SysDictionaryDTO> SCHR6List = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),fl.constant.facade.framework.constant.DictionaryConstant.RC_CP_MOD_EXT_INFO_SCHR6);
		view.addObject("SCHR6List", SCHR6List);
		BaseLogUtils.info(logger, "toAudBscBookListPage", "跳转到信审基础台账列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/** 到信审遗留问题页面 */
	@RequestMapping(value = "/toAudRemainProPage.do", method = { RequestMethod.GET})
	public ModelAndView toAudRemainProPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("project/prjbscinfo/audRemainProPage");
		String id = request.getParameter("id");
		view.addObject("id", id);
		BaseLogUtils.info(logger, "toAudRemainProPage", "跳转到到信审遗留问题页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/** 到信审遗留问题页面 */
	@RequestMapping(value = "/selectById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object selectById(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "getCarById", "获取车辆资产数据主键参数不存在.", CurrentThreadContext.getCurrentUserName());
			return result;
		}

		try {
			AudStandingBookVO vo = audStandingBookService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "selectById", "获取信审遗留问题数据不存在.ID:" + id, CurrentThreadContext.getCurrentUserName());
			}else{
				BaseLogUtils.info(logger, "selectById", "获取信审遗留问题数据成功.ID:" + id, CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "selectById", "获取信审遗留问题数据失败.ID:" + id + "-ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "selectById", "获取信审遗留问题数据,系统错误.ID:" + id + "-ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**  到信审基础台账 新增/修改页面 */
	@RequestMapping(value = "/toAudBscBookAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAudBscBookAddPage(HttpServletRequest request, HttpServletResponse response) {
		String projectId = request.getParameter("projectId");//项目ID
		String proIntId = request.getParameter("proIntId");//流程ID
		String taskDefKey = request.getParameter("taskDefKey");//任务KEY
		String taskNm = request.getParameter("taskNm");//节点名称
		String prdTypCd = request.getParameter("prdTypCd");//产品类型
		String isDetail = request.getParameter("isDetail");
		ModelAndView view = new ModelAndView("audit/audBscBook/audBscBookAdd");
		view.addObject("projectId", projectId);
		view.addObject("proIntId", proIntId);
		view.addObject("taskDefKey", taskDefKey);
		view.addObject("taskNm", taskNm);
		view.addObject("prdTypCd", prdTypCd);
		view.addObject("isDetail", isDetail);
		//根据任务KEY判断 初审OR复审
		if(AudStandingBookConstant.AUD_PRJ_FIRST_NODE.contains(taskDefKey)){
			view.addObject("reviewTypeCd", AudStandingBookConstant.AUD_FIRST_NODE_TYPE);
			view.addObject("reviewTypeCdNm", AudStandingBookConstant.AUD_FIRST_NODE_TYPE_NM);
		}else if(AudStandingBookConstant.AUD_PRJ_REVIEW_NODE.contains(taskDefKey)){
			view.addObject("reviewTypeCd", AudStandingBookConstant.AUD_REVIEW_NODE_TYPE);
			view.addObject("reviewTypeCdNm", AudStandingBookConstant.AUD_REVIEW_NODE_TYPE_NM);
		}else if(AudStandingBookConstant.AUD_PRJ_FINAL_NODE.contains(taskDefKey)){
			view.addObject("reviewTypeCd", AudStandingBookConstant.AUD_FINAL_NODE_TYPE);
			view.addObject("reviewTypeCdNm", AudStandingBookConstant.AUD_FINAL_NODE_TYPE_NM);
		}
		view.addObject("taskDefKey", taskDefKey);
		
		//原因分类
		List<KeyValueVO> reasonTypeCdList = this.audStandingBookService.searchReasonTypeCdList();
		view.addObject("reasonTypeCdList", reasonTypeCdList);
		//品牌级别
		List<KeyValueVO> brandLevelCdList = this.audStandingBookService.searchBrandLevelCdList();
		view.addObject("brandLevelCdList", brandLevelCdList);
		//是否
		List<KeyValueVO> yesOrNoCdList = this.audStandingBookService.searchYesOrNoCdList();
		view.addObject("yesOrNoCdList", yesOrNoCdList);
		//流程审核意见
		List<KeyValueVO> processOpinionCdList = this.audStandingBookService.searchProcessOpinionCdList();
		view.addObject("processOpinionCdList", processOpinionCdList);
		
		//查询担保性质
		StringBuffer guarantyProCd = new StringBuffer(""),guarantyProCdNm = new StringBuffer("");
		if(StringUtils.isNotEmpty(projectId)){
			List<PrjCstBscInfoVO> guarantorList = this.prjAuditFlowService.searchGuarantorList(Long.valueOf(projectId));
			if(CollectionUtils.isNotEmpty(guarantorList)){
				for (PrjCstBscInfoVO prjCstBscInfoVO : guarantorList) {
					Long guaCstId = prjCstBscInfoVO.getCstId();
					if(null!=prjCstBscInfoVO){
						CstBscInfoVO cstBscInfoVO = this.cstBscInfoService.selectDetailById(guaCstId);//客户信息
						if(null!=cstBscInfoVO){
							CstExtInfoVO cstExtInfoVO = cstBscInfoVO.getCstExtInfoVO();
							if(null!=cstExtInfoVO){
								guarantyProCd.append(cstExtInfoVO.getSchr6()+";");
								guarantyProCdNm.append(cstExtInfoVO.getGuarTypCdNm()+";");
							}
						}
					}
				}
			}
		}
		String guarantyProCdString = "";
		String guarantyProCdNmString = "";
		if(StringUtils.isNotEmpty(guarantyProCd.toString()) && guarantyProCd.toString().endsWith(";")){
			guarantyProCdString  = guarantyProCd.toString().substring(0, guarantyProCd.toString().length()-1);
		}
		if(StringUtils.isNotEmpty(guarantyProCdNm.toString()) && guarantyProCdNm.toString().endsWith(";")){
			guarantyProCdNmString  = guarantyProCdNm.toString().substring(0, guarantyProCdNm.toString().length()-1);
		}
		view.addObject("guarantyProCd", guarantyProCdString);
		view.addObject("guarantyProCdNm", guarantyProCdNmString);
		
		//查询小数位数控制
		
		
		BaseLogUtils.info(logger, "toAudBscBookAddPage", "跳转到修改页面.[proIntId="+proIntId+",taskDefKey="+taskDefKey+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/** 获取信审基础台账信息*/
	@RequestMapping(value = "/getAudBscBook.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getAudBscBook(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String projectId = request.getParameter("projectId");
		String proIntId = request.getParameter("proIntId");
		String taskDefKey = request.getParameter("taskDefKey");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(projectId) || StringUtils.isEmpty(proIntId) || StringUtils.isEmpty(taskDefKey)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_AUD_PROINT_ID_NOT_EMPTY + SysLogConstant.LOG_AUD_TASK_ID_NOT_EMPTY);
			BaseLogUtils.error(logger, "getAudBscBook", "获取数据,缺少必要参数条件.[proIntId="+proIntId+",taskDefKey="+taskDefKey+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			AuditStandingBookQueryCondition qc = new AuditStandingBookQueryCondition();
			List<Long> prjIdList = new ArrayList<Long>();
			prjIdList.add(Long.valueOf(projectId));
			qc.setProjectIdList(prjIdList);
			qc.setBookTypeCd(AudStandingBookConstant.AUD_TYP_CD_BSC);//设置台账类型查询条件
			qc.setProIntId(proIntId);
			qc.setTaskDefKey(taskDefKey);
			AudStandingBookVO vo = this.audStandingBookService.selectAudStandingBookByQc(qc);
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getAudBscBook", "获取数据,数据不存在.[proIntId="+proIntId+",taskDefKey="+taskDefKey+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getAudBscBook", "获取数据.[proIntId="+proIntId+",taskDefKey="+taskDefKey+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getAudBscBook", "获取失败.[proIntId="+proIntId+",taskDefKey="+taskDefKey+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getAudBscBook", "获取失败.[proIntId="+proIntId+",taskDefKey="+taskDefKey+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 到动态字段组件页面-信审基础台账农机新增字段
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toFarmDynamicFldPage.do", method = { RequestMethod.GET,RequestMethod.POST })
	public ModelAndView toFarmDynamicFldPage(HttpServletRequest request, HttpServletResponse response) {
		String bizTypCd = request.getParameter("bizTypCd");
		String bizCd = request.getParameter("bizCd");
		ModelAndView view = new ModelAndView("audit/audBscBook/audBscBookAddDynamicPage");
		if(StringUtils.isNotEmpty(bizTypCd) && StringUtils.isNotEmpty(bizCd)){
			view.addObject("bizTypCd", bizTypCd);
			view.addObject("bizCd", bizCd);
		}else{
			view.addObject("bizTypCd", "");
			view.addObject("bizCd", "");
		}
		return view;
	}
	
	//************************************************核价基础台账********************************************/
	/**
	 * 到核价基础台账列表页面
	 */
	@RequestMapping(value = "/toCorePriceBookListPage.do", method = { RequestMethod.GET})
	public ModelAndView toCorePriceBookListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("audit/audCorePrcBook/audCorePrcBookList");
		BaseLogUtils.info(logger, "toCorePriceBookListPage", "跳转到核价基础台账列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到核价基础台账 新增/修改页面
	 */
	@RequestMapping(value = "/toCorePrcBookAddPage.do", method = { RequestMethod.GET})
	public ModelAndView toCorePrcBookAddPage(HttpServletRequest request, HttpServletResponse response) {
		String projectId = request.getParameter("projectId");//项目ID
		String proIntId = request.getParameter("proIntId");//流程ID
		String prjPrdId = request.getParameter("prjPrdId");//项目产品ID
		String isDetail = request.getParameter("isDetail");
		String buOrgCd = request.getParameter("buOrgCd");//项目所属事业部
		String fromCddFlag = request.getParameter("fromCddFlag");//车抵贷标识
		String prjPrdChangeFlag = request.getParameter("prjPrdChangeFlag");//换车标识
		ModelAndView view = new ModelAndView("audit/audCorePrcBook/audCorePrcBookAdd");
		BaseLogUtils.info(logger, "toCorePrcBookAddPage", "跳转到核价基础台账新增/修改页面.", CurrentThreadContext.getCurrentUserName());
		String previewCorePrcInfo = "";
		//获取预览核价信息
		if(StringUtils.isNotEmpty(prjPrdId) && StringUtils.isEmpty(fromCddFlag)){
			try {
				if(PropertiesCacheUtils.getProperty(SystemConstant.FL_BUS_BU_ORG_CD).equals(buOrgCd)){
					previewCorePrcInfo = this.audStandingBookService.getPreviewCorePrcInfoForBusKC(Long.valueOf(prjPrdId));
				} else if (PropertiesCacheUtils.getProperty(SystemConstant.FL_BUS_XNY_ORG_CD).equals(buOrgCd)) {
					previewCorePrcInfo = this.audStandingBookService.getPreviewCorePrcInfoForXNY(Long.valueOf(prjPrdId));
				} else{
					previewCorePrcInfo = this.audStandingBookService.getPreviewCorePrcInfo(Long.valueOf(prjPrdId));
				}
			} catch (Exception e) {
				BaseLogUtils.info(logger, "toCorePrcBookAddPage", "===获取核价信息异常===Detail:"+e.getMessage(),CurrentThreadContext.getCurrentUserName());
			BaseLogUtils.error(logger, "-", "异常", e);
			}
		}
		view.addObject("previewCorePrcInfo", previewCorePrcInfo);
		view.addObject("projectId", projectId);
		view.addObject("proIntId", proIntId);
		view.addObject("prjPrdId", prjPrdId);
		view.addObject("isDetail", isDetail);
		view.addObject("buOrgCd", buOrgCd);
		view.addObject("fromCddFlag", fromCddFlag);
		view.addObject("prjPrdChangeFlag", prjPrdChangeFlag);
		/**
		 * 查询价格 指导价:项目产品价格 建议价格:产品价格
		 */
		Double prjPrdPc = 0d;
		Double prdPc = 0d;
		try {
			if(StringUtils.isNotEmpty(fromCddFlag)){
				OdrQuatPrpsQC oqpQC = new OdrQuatPrpsQC();
				oqpQC.setOdrId(Long.valueOf(projectId));
				oqpQC.setIsDel(BaseConstant.IS_YESNO_NO);
				BaseLogUtils.info(logger, "toModifyPage", "=车抵贷-查询方案信息Start=odrId:"+projectId+",oqpQC:"+JSON.toJSONString(oqpQC), CurrentThreadContext.getCurrentUserName());
				List<OdrQuatPrpsDTO> selectOdrQuatPrpsList = this.odrQuatPrpsApiService.selectOdrQuatPrpsList(oqpQC);
				BaseLogUtils.info(logger, "toModifyPage", "=车抵贷-查询方案信息End=odrId:"+projectId+",selectOdrQuatPrpsList:"+JSON.toJSONString(selectOdrQuatPrpsList), CurrentThreadContext.getCurrentUserName());
				if(CollectionUtils.isNotEmpty(selectOdrQuatPrpsList)){
					OdrQuatPrpsDTO odrQuatPrpsDTO = selectOdrQuatPrpsList.get(0);
					if(null!=odrQuatPrpsDTO.getContAmt()){
						prjPrdPc = DecimalUtils.convertFenToYuan(odrQuatPrpsDTO.getContAmt());
						prdPc = DecimalUtils.convertFenToYuan(odrQuatPrpsDTO.getContAmt());
					}
					
				}
			}else{
				PrjPrdBscInfoVO prjPrdBscInfoVO = this.prjPrdBscInfoService.selectPrjPrdBscAndDetailInfoById(prjPrdId.toString());
				prjPrdPc = prjPrdBscInfoVO.getGuidePc();//项目产品价格
				PrjPrdParamConfigVO prdDetail = vehicleStyleService.getPrdDetail(prjPrdBscInfoVO.getStyleId());
				String guidePc = prdDetail.getGuidePc();
				if(StringUtils.isNotBlank(guidePc)){
					prdPc = Double.valueOf(guidePc);
				}
			}
		} catch (Exception e) {
			BaseLogUtils.info(logger, "toCorePrcBookAddPage", "===核价信息查询价格进行对比异常===Detail:"+e.getMessage(), CurrentThreadContext.getCurrentUserName());
			BaseLogUtils.error(logger, "-", "异常", e);
		}
		view.addObject("prjPrdPc", prjPrdPc!=null?prjPrdPc:"");
		view.addObject("prdPc", prdPc!=null?prdPc:"");

		return view;
	}
	
	/** 获取核价基础台账信息*/
	@RequestMapping(value = "/getAudCorePrcBook.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getAudCorePrcBook(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String projectId = request.getParameter("projectId");
		String proIntId = request.getParameter("proIntId");
		String prjPrdId = request.getParameter("prjPrdId");//项目产品ID
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(projectId) || StringUtils.isEmpty(proIntId) || StringUtils.isEmpty(prjPrdId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_AUD_PROINT_ID_NOT_EMPTY + SysLogConstant.LOG_AUD_TASK_ID_NOT_EMPTY);
			BaseLogUtils.error(logger, "getAudCorePrcBook", "获取数据,缺少必要参数条件.[proIntId="+proIntId+",prjPrdId="+prjPrdId+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			AuditStandingBookQueryCondition qc = new AuditStandingBookQueryCondition();
			List<Long> prjIdList = new ArrayList<Long>();
			prjIdList.add(Long.valueOf(projectId));
			qc.setProjectIdList(prjIdList);
			qc.setBookTypeCd(AudStandingBookConstant.AUD_TYP_CD_PRCE);//设置台账类型查询条件
			qc.setProIntId(proIntId);
			qc.setPrjPrdId(Long.valueOf(prjPrdId));
			AudStandingBookVO vo = this.audStandingBookService.selectAudStandingBookByQc(qc);
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getAudCorePrcBook", "获取数据,数据不存在.[proIntId="+proIntId+",prjPrdId="+prjPrdId+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getAudCorePrcBook", "获取数据.[proIntId="+proIntId+",prjPrdId="+prjPrdId+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getAudCorePrcBook", "获取失败.[proIntId="+proIntId+",prjPrdId="+prjPrdId+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getAudCorePrcBook", "获取失败.[proIntId="+proIntId+",prjPrdId="+prjPrdId+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	//************************************************信审驳回台账********************************************/
	/**
	 * 到信审驳回台账列表页面
	 */
	@RequestMapping(value = "/toAudRejectBookListPage.do", method = { RequestMethod.GET})
	public ModelAndView toAudRejectBookListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("audit/audRejectBook/audRejectBookList");
		BaseLogUtils.info(logger, "toAudRejectBookListPage", "跳转到信审驳回台账列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	//************************************************放款基础台账********************************************/
	/**
	 * 到放款基础台账列表页面
	 */
	@RequestMapping(value = "/toLoanBookListPage.do", method = { RequestMethod.GET})
	public ModelAndView toLoanBookListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("audit/audLoanBook/audLoanBookList");
		BaseLogUtils.info(logger, "toLoanBookListPage", "跳转到放款基础台账列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	//************************************************续保基础台账********************************************/
	/**
	 * 到续保基础台账列表页面
	 */
	@RequestMapping(value = "/toXbBookListPage.do", method = { RequestMethod.GET})
	public ModelAndView toXbBookListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("audit/audXbBook/audXbBookList");
		BaseLogUtils.info(logger, "toXbBookListPage", "跳转到续保基础台账列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

    //************************************************评审录单台账********************************************/
    /**
     * 到评审录单台账列表页面
     */
    @RequestMapping(value = "/toPLBookListPage.do", method = { RequestMethod.GET})
    public ModelAndView toPLBookListPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("audit/audPlBook/audPlBookList");
        // 项目类型
        List<KeyValueVO> projectTypeList = getKeyValueList(DictionaryConstant.CODE_PRJ_TYPE_CD);
        // 项目状态
        List<KeyValueVO> prjStsCdList = getKeyValueList(DictionaryConstant.CODE_AUD_STS_CD);
        view.addObject("projectTypeList",projectTypeList);
        view.addObject("prjStsCdList",prjStsCdList);
        BaseLogUtils.newLogger("toPLBookListPage.跳转到评审录单台账列表页面." + JSONObject.toJSONString(view)).info();
        return view;
    }

	//************************************************放款录单台账********************************************/
	/**
	 * 到放款录单台账列表页面
	 */
	@RequestMapping(value = "/toFLBookListPage.do", method = {RequestMethod.GET})
	public ModelAndView toFLBookListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("audit/audFlBook/audFlBookList");
		// 项目类型
		List<KeyValueVO> projectTypeList = this.getKeyValueList(DictionaryConstant.CODE_PRJ_TYPE_CD);
		//付款状态
		List<KeyValueVO> payStsCdList = this.getKeyValueList(CapPayInfoConstant.CODE_PAY_STS_CD);
		//是否
		List<KeyValueVO> yesOrNoCdList = this.getKeyValueList(DictionaryConstant.CODE_SYS_YES_NO_CD);
		view.addObject("projectTypeList", projectTypeList);
		view.addObject("payStsCdList", payStsCdList);
		view.addObject("yesOrNoCdList", yesOrNoCdList);
		BaseLogUtils.info(logger, "toFLBookListPage", "跳转到放款录单台账列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	//******************************************************************************************************/
	
	
	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("audit/audStandingBook/modify");
		view.addObject("id", id);
		BaseLogUtils.info(logger, "toModifyPage", "跳转到修改页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String bookTypCd = request.getParameter("bookTypCd");//台账类型
		//String crtUsrNm = request.getParameter("crtUsrNm");//操作人
		String crtRlNm = request.getParameter("crtRlNm");//操作人
		String pNo = request.getParameter("pNo");//流程编号
		String cstNm = request.getParameter("cstNm");//承租人
		String crtStartDt = request.getParameter("crtStartDt");//添加日期(起)
		String crtEndDt = request.getParameter("crtEndDt");//添加日期(止)
		String schr6 = request.getParameter("schr6");//审批类型
        Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		AuditStandingBookQueryCondition qc = new AuditStandingBookQueryCondition();
		
		qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
		
		if (StringUtils.isNotEmpty(bookTypCd)) {
			qc.setBookTypeCd(bookTypCd);
		}
		if (StringUtils.isNotEmpty(schr6)) {
			qc.setSchr_6(schr6);//审批类型
		}
		if(StringUtils.isNotEmpty(crtRlNm)){
			qc.setCrtRlNm(crtRlNm);
		}
		if(StringUtils.isNotEmpty(pNo)){
			qc.setPNo(pNo);
		}
		if(StringUtils.isNotEmpty(cstNm)){
			qc.setCstNm(cstNm);
		}
		if(StringUtils.isNotEmpty(crtStartDt)){
			qc.setCrtStartDt(DateUtils.formatStringToDate(crtStartDt, DateUtils.YYYY_MM_DD));
		}
		if(StringUtils.isNotEmpty(crtEndDt)){
			Date date = DateUtils.formatStringToDate(crtEndDt, DateUtils.YYYY_MM_DD);
			Calendar cal = Calendar.getInstance();
			cal.setTime(date);
			cal.add(Calendar.DATE, 1);
			qc.setCrtEndDt(DateUtils.formatDate(cal.getTime(), DateUtils.YYYY_MM_DD));
		}

		//承租人、流程编号  其余查询条件加入一年内限制
		if (StringUtils.isEmpty(qc.getCstNm()) && StringUtils.isEmpty(qc.getPNo()) && StringUtils.isEmpty(crtStartDt)){
			//先判断
			Calendar instance = Calendar.getInstance();
			instance.setTime(new Date());
			instance.add(Calendar.YEAR, -1);
			instance.add(Calendar.DATE, 1);
			qc.setCrtStartDt(DateUtils.formatDate(instance.getTime(), DateUtils.YYYY_MM_DD));
		}
		//驳回台账/放款台账 设置评审结果查询条件为:通过/驳回   过滤审核中的
		if(AudStandingBookConstant.AUD_TYP_CD_LOAN.equals(bookTypCd) 
				|| AudStandingBookConstant.AUD_TYP_CD_TRUN.equals(bookTypCd)){
			qc.setIsNotReviewResultCd(AudStandingBookConstant.AUD_REVIEW_RESULT_CD_BEING);
		}else if(AudStandingBookConstant.AUD_TYP_CD_BSC.equals(bookTypCd)){
			//基础台账  过滤掉审核不通过的
			qc.setIsNotReviewResultCd(AudStandingBookConstant.AUD_REVIEW_RESULT_CD_REFUSE);
		}
		
		page.setCondition(qc);

		BaseLogUtils.newLogger("查询数据. page:{},userName:{}", JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName()).info();
		Pager pager = this.audStandingBookService.searchListPage(page);
		List<AudStandingBookVO> list = (List<AudStandingBookVO>) pager.getResultList();
		ListPageVO<AudStandingBookVO> listPage = new ListPageVO<AudStandingBookVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			AudStandingBookVO vo = this.audStandingBookService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getById", "获取数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		AudStandingBookVO entity = null;
		try {
			entity = this.getRequestParamForAdd(request);

			AuditStandingBookDTO dto = new AuditStandingBookDTO();
			BeanUtils.copyProperties(entity, dto);
			List<AudRejectOpinionVO> audRejectOpinionVOList = entity.getAudRejectOpinionVOList();
			if (CollectionUtils.isNotEmpty(audRejectOpinionVOList)) {
				List<AuditRejectOpinionDTO> audRejectOpinionDTOList = new ArrayList<>();
				for (AudRejectOpinionVO audRejectOpinionVO : audRejectOpinionVOList) {
					AuditRejectOpinionDTO auditRejectOpinionDTO = new AuditRejectOpinionDTO();
					BeanUtils.copyProperties(audRejectOpinionVO, auditRejectOpinionDTO);
					auditRejectOpinionDTO.setPayId(audRejectOpinionVO.getCapPayId());
					audRejectOpinionDTOList.add(auditRejectOpinionDTO);
				}
				dto.setAudRejectOpinionDTOList(audRejectOpinionDTOList);
			}

			AddAudStandingBookRequest addRequest = new AddAudStandingBookRequest(dto, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
			ResponseData<Long> responseData = auditStandingBookService.addAudStandingBook(addRequest);
			if (!ResponseData.SUCCESS_CODE.equals(responseData.getCode())) {
				throw new BaseException(BaseExceptionConstant.DATABASE_0201_NAME, "新增数据失败");
			}
			result.setData(responseData.getData());
			BaseLogUtils.info(logger, "add", "新增数据.[id="+responseData.getData()+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		AudStandingBookVO entity = null;
		try {
			entity = this.getRequestParamForModify(request);
			entity.setId(Long.valueOf(id));

			AuditStandingBookDTO dto = new AuditStandingBookDTO();
			BeanUtils.copyProperties(entity, dto);
			ModifyAudStandingBookRequest modifyRequest = new ModifyAudStandingBookRequest(dto);
			ResponseData responseData = auditStandingBookService.modifyAudStandingBook(modifyRequest);
			if (!ResponseData.SUCCESS_CODE.equals(responseData.getCode())) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	/**
	 * 信审遗留问题
	 */
	@RequestMapping(value = "/addAudRemainPro.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object addAudRemainPro(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String audRemain = request.getParameter("audRemain");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.newLogger("addAudRemainPro修改数据,主键不存在.[id="+id+"]").info();
			return result;
		}
		try {
			AuditStandingBookDTO dto = new AuditStandingBookDTO();
			dto.setId(Long.valueOf(id));
			dto.setBookTypeCd(AuditConstans.AudTypeCdEnum.AUD_TYP_CD_PL.key());
			dto.setAudRemainPro(audRemain);
			BaseLogUtils.newLogger("addAudRemainPro.修改信审遗留问题：dto:{}",JSONObject.toJSONString(dto)).info();
			ModifyAudStandingBookRequest modifyRequest = new ModifyAudStandingBookRequest(dto);
			ResponseData responseData = auditStandingBookService.modifyAudStandingBook(modifyRequest);
			if (!ResponseData.SUCCESS_CODE.equals(responseData.getCode())) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.newLogger("addAudRemainPro.修改失败.[id="+id+"] 操作人：{}" , CurrentThreadContext.getCurrentUserName()).info();
			}
			BaseLogUtils.newLogger("addAudRemainPro.修改成功.[id="+id+"] 操作人：{}" , CurrentThreadContext.getCurrentUserName()).info();
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newLogger("addAudRemainPro.修改失败，ID：{} 操作人：{}" ,id, CurrentThreadContext.getCurrentUserName()).info();
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newLogger("addAudRemainPro.修改失败.[id="+id+"] 操作人：{}" , CurrentThreadContext.getCurrentUserName()).setThrowable(ex).error(LogExceptionEnum.COMMON_CODE_0002);
		}
		return result;
	}

	@RequestMapping(value = "/modifyReceiveState.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyReceiveState(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String receiveState = request.getParameter("receiveState");
		String bookTypeCd = request.getParameter("bookTypeCd");
		String prjId = request.getParameter("prjId");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if (StringUtils.isEmpty(id)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		AudStandingBookVO entity = new AudStandingBookVO();
		try {
			if (StringUtils.isEmpty(bookTypeCd)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "台账类型不能为空");
			}
			entity.setId(Long.valueOf(id));
			entity.setBookTypeCd(bookTypeCd);
			entity.setReceiveState(receiveState);
            //领取人
            entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
            entity.setCrtUsrNm(CurrentThreadContext.getCurrentUserName());
            //领取时间
            entity.setReceiveTm(new Date());
            entity.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
            entity.setMdfTm(new Date());
			AuditStandingBookDTO dto = new AuditStandingBookDTO();
			BeanUtils.copyProperties(entity, dto);
			BaseLogUtils.info(logger, "modify", "调用录单领取 req=" + JSONObject.toJSONString(dto), CurrentThreadContext.getCurrentUserName());
			ResponseData responseData = auditStandingBookService.receiveRecord(dto);
			BaseLogUtils.info(logger, "modify", "调用录单领取 res=" + JSONObject.toJSONString(responseData), CurrentThreadContext.getCurrentUserName());
			if (!ResponseData.SUCCESS_CODE.equals(responseData.getCode())) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				if (StringUtils.isNotEmpty(responseData.getMessage())) {
					result.setInfo(responseData.getMessage());
				} else {
					result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				}
				BaseLogUtils.info(logger, "modify", "修改失败.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			//放款录单领取成功 发送短信
			if (AudStandingBookConstant.AUD_TYP_CD_FL.equals(bookTypeCd) &&
					BaseConstant.IS_YESNO_YES == result.getSuccess()
					&& StringUtils.isNotEmpty(prjId)) {
				BaseLogUtils.newLogger("modifyReceiveState 查询项目信息Start prjId:{}", prjId).info();
				PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(prjId));
				BaseLogUtils.newLogger("modifyReceiveState 查询项目信息End prjId:{},prjBscInfoVO:{}", prjId, JSON.toJSONString(prjBscInfoVO)).info();
				if (prjBscInfoVO != null && StringUtils.isNotEmpty(prjBscInfoVO.getCstMgrId())) {
					try {
						BaseLogUtils.newLogger("modifyReceiveState 查询客户经理信息Start cstMgrId:{},sysCd:{},orgCd:{}", prjBscInfoVO.getCstMgrId(), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd()).info();
						SysUsrDTO sysUsrDTO = this.sysUsrApiService.selectSysUsrById(prjBscInfoVO.getCstMgrId(), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
						BaseLogUtils.newLogger("modifyReceiveState 查询客户经理信息End cstMgrId:{},sysUsrDTO:{}", prjBscInfoVO.getCstMgrId(), JSON.toJSONString(sysUsrDTO)).info();
						if (null != sysUsrDTO && StringUtils.isNotEmpty(sysUsrDTO.getMp())) {
							String[] params = new String[]{prjBscInfoVO.getCstMgrNm(), entity.getCrtUsrNm()};
							//发送短信对象
							SmsSendParamDTO smsSendParamDTO = new SmsSendParamDTO();
							smsSendParamDTO.setMp(sysUsrDTO.getMp());
							smsSendParamDTO.setCode(AudStandingBookConstant.FL_RECEIVE_MSG_TYPE_CD);
							smsSendParamDTO.setParams(params);
							smsSendParamDTO.setUsrId(CurrentThreadContext.getCurrentUserId());
							smsSendParamDTO.setType(0);
							BaseLogUtils.newLogger("modifyReceiveState 发送短信Start cstMgrId:{},smsSendParamDTO:{}", prjBscInfoVO.getCstMgrId(), JSON.toJSONString(smsSendParamDTO)).info();
							DataResultDTO sendSmsResultDTO = this.smsAddApiService.sendSMS(smsSendParamDTO);
							BaseLogUtils.newLogger("modifyReceiveState 发送短信End cstMgrId:{},sendSmsResultDTO:{}", prjBscInfoVO.getCstMgrId(), JSON.toJSONString(sendSmsResultDTO)).info();
						}
					} catch (Exception e) {
						BaseLogUtils.newLogger("modifyReceiveState 发送短信异常 prjId:{},cstMgrId:{},errMsg:{}", prjId, prjBscInfoVO.getCstMgrId(), e).info();
					}
				}
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id=" + id + "] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	//********************私有方法********************//
	/**
	 * 获取参数信息
	 * @param request
	 * @return
	 * @throws BaseException
	 */
	private AudStandingBookVO getRequestParam(HttpServletRequest request)throws BaseException{
		String bookTypeCd = request.getParameter("bookTypeCd");//台账类型
		if(StringUtils.isEmpty(bookTypeCd)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		String projectId = request.getParameter("projectId");//项目ID
		String prjPrdId = request.getParameter("prjPrdId");//项目产品ID
		String payId = request.getParameter("payId");//项目支付表ID
		String proIntId = request.getParameter("proIntId");//流程实例ID
		String taskId = request.getParameter("taskId");//任务ID
		String taskDefKey = request.getParameter("taskDefKey");//任务定义key
		String taskName = request.getParameter("taskName");//任务定义key
		String reviewTypeCd = request.getParameter("reviewTypeCd");//评审类别
		String lenWidHig = request.getParameter("lenWidHig");//校准货箱内部
		String pricingInfo = request.getParameter("pricingInfo");//校准核价信息
		
		/*String reasonTypeCd = request.getParameter("reasonTypeCd");//原因分类
		String brandLevelCd = request.getParameter("brandLevelCd");//品牌级别
		String isNew = request.getParameter("isNew");//是否新单
		String processOpinionCd = request.getParameter("processOpinionCd");//流程审核意见
		String guarantyProCd = request.getParameter("guarantyProCd");//担保性质
		String firstPaymentPct = request.getParameter("firstPaymentPct");//首付比率
		String depositPct = request.getParameter("depositPct");//保证金比率
		String financingAmt = request.getParameter("financingAmt");//融资总金额
		String returnPct = request.getParameter("returnPct");//收益率
		String irrPct = request.getParameter("irrPct");//IRR(内部收益率)
		String consultingOneAmt = request.getParameter("consultingOneAmt");//咨询费1
		String consultingTwoAmt = request.getParameter("consultingTwoAmt");//咨询费2
		String annualRatePct = request.getParameter("annualRatePct");//年利率
		String policyCd = request.getParameter("policyCd");//政策类型
		String repaymentPeriod = request.getParameter("repaymentPeriod");//大额还款期次
*/
		AudStandingBookVO audStandingBookVO = new AudStandingBookVO();
		if(StringUtils.isNotEmpty(projectId)){
			audStandingBookVO.setProjectId(Long.valueOf(projectId));
		}
		if(StringUtils.isNotEmpty(prjPrdId)){
			audStandingBookVO.setPrjPrdId(Long.valueOf(prjPrdId));
		}
		if(StringUtils.isNotEmpty(payId)){
			audStandingBookVO.setPayId(Long.valueOf(payId));
		}
		audStandingBookVO.setProIntId(proIntId);
		audStandingBookVO.setTaskId(taskId);
		audStandingBookVO.setTaskDefKey(taskDefKey);
		audStandingBookVO.setTaskName(taskName);
		audStandingBookVO.setBookTypeCd(bookTypeCd);
		audStandingBookVO.setReviewTypeCd(reviewTypeCd);
		audStandingBookVO.setReviewResultCd(AudStandingBookConstant.AUD_REVIEW_RESULT_CD_BEING);//审核中
		audStandingBookVO.setLenWidHig(lenWidHig);
		audStandingBookVO.setPricingInfo(pricingInfo);
		/*if(AudStandingBookConstant.AUD_TYP_CD_BSC.equals(bookTypeCd)){//信审基础台账
			AudBasicsBookVO audBasicsBookVO = new AudBasicsBookVO();
			audBasicsBookVO.setReasonTypeCd(reasonTypeCd);
			audBasicsBookVO.setBrandLevelCd(brandLevelCd);
			if(StringUtils.isNotEmpty(isNew)){
				audBasicsBookVO.setIsNew(Integer.valueOf(isNew));
			}else{
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "是否新单不能为空.");
			}
			audBasicsBookVO.setProcessOpinionCd(processOpinionCd);
			audBasicsBookVO.setGuarantyProCd(guarantyProCd);
			if(StringUtils.isNotEmpty(firstPaymentPct)){
				audBasicsBookVO.setFirstPaymentPct(Double.valueOf(firstPaymentPct));
			}
			if(StringUtils.isNotEmpty(depositPct)){
				audBasicsBookVO.setDepositPct(Double.valueOf(depositPct));
			}
			if(StringUtils.isNotEmpty(financingAmt)){
				audBasicsBookVO.setFinancingAmt(DecimalUtils.mul(Double.valueOf(financingAmt), 100));
			}
			if(StringUtils.isNotEmpty(returnPct)){
				audBasicsBookVO.setReturnPct(Double.valueOf(returnPct));
			}
			if(StringUtils.isNotEmpty(irrPct)){
				audBasicsBookVO.setIrrPct(Double.valueOf(irrPct));
			}
			if(StringUtils.isNotEmpty(consultingOneAmt)){
				audBasicsBookVO.setConsultingOneAmt(DecimalUtils.mul(Double.valueOf(consultingOneAmt), 100));
			}
			if(StringUtils.isNotEmpty(consultingTwoAmt)){
				audBasicsBookVO.setConsultingTwoAmt(DecimalUtils.mul(Double.valueOf(consultingTwoAmt), 100));
			}
			if(StringUtils.isNotEmpty(annualRatePct)){
				audBasicsBookVO.setAnnualRatePct(Double.valueOf(annualRatePct));
			}
			audBasicsBookVO.setPolicyCd(policyCd);
			if(StringUtils.isNotEmpty(repaymentPeriod)){
				audBasicsBookVO.setRepaymentPeriod(Long.valueOf(repaymentPeriod));
			}
			
			audStandingBookVO.setAudBasicsBookVO(audBasicsBookVO);
		}*/
		
		return audStandingBookVO;
	}
	
	/**
	 * 获取请求参数(新增)
	 * @param request 请求
	 * @return 
	 */
	private AudStandingBookVO getRequestParamForAdd(HttpServletRequest request)throws BaseException{
		AudStandingBookVO audStandingBookVO = this.getRequestParam(request);
		audStandingBookVO.setCrtTm(new Date());
		audStandingBookVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
		return audStandingBookVO;
	}
	
	/**
	 * 获取请求参数(修改)
	 * @param request 请求
	 * @return 
	 */
	private AudStandingBookVO getRequestParamForModify(HttpServletRequest request)throws BaseException{
		AudStandingBookVO audStandingBookVO = this.getRequestParam(request);
		audStandingBookVO.setMdfTm(new Date());
		audStandingBookVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		return audStandingBookVO;
	}
	
	/**
	 * 导出台账
	 */
	@RequestMapping(value = "/exportBook.do", method = { RequestMethod.POST,RequestMethod.GET })
	@ResponseBody
	public Object exportBook(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_BK_EXPORT_SUCC);
		String bookTypCd = request.getParameter("bookTypCd");//台账类型
		String crtRlNm = request.getParameter("crtRlNm");//操作人
		String pNo = request.getParameter("pNo");//流程编号
		String cstNm = request.getParameter("cstNm");//承租人
		String crtStartDt = request.getParameter("crtStartDt");//添加日期(起)
		String crtEndDt = request.getParameter("crtEndDt");//添加日期(止)
		String bookCodes = request.getParameter("bookCodes");//台账IDList
		
		if(StringUtils.isEmpty(bookTypCd)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("台账类型不能为空.");
			BaseLogUtils.info(logger, "exportBook", "导出台账,台账类型不能为空.");
			return result;
		}
		try {
			AudStandingBookQueryCondition condition = new AudStandingBookQueryCondition();
			
			condition.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
			
			condition.setBookTypeCd(bookTypCd);
			if(StringUtils.isNotEmpty(crtRlNm)){
				condition.setCrtRlNm(crtRlNm);
			}
			if(StringUtils.isNotEmpty(pNo)){
				condition.setpNo(pNo);
			}
			if(StringUtils.isNotEmpty(cstNm)){
				condition.setCstNm(cstNm);
			}
			if(StringUtils.isNotEmpty(crtStartDt)){
				condition.setCrtStartDt(DateUtils.formatStringToDate(crtStartDt, DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(crtEndDt)){
			//	condition.setCrtEndDt(DateUtils.formatStringToDate(crtEndDt, DateUtils.YYYY_MM_DD));
				Date date = DateUtils.formatStringToDate(crtEndDt, DateUtils.YYYY_MM_DD);
				Calendar cal = Calendar.getInstance();
				cal.setTime(date);
				cal.add(Calendar.DATE, 1);
				condition.setCrtEndDt(DateUtils.formatDate(cal.getTime(), DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(bookCodes)){
				List<String> bookCodeList = new ArrayList<String>();
				JSONArray bookCodesArray = JSONArray.fromObject(bookCodes);
				for (Object object : bookCodesArray) {
					bookCodeList.add(object.toString());
				}
				condition.setBookCodeList(bookCodeList);
			}
			String path = this.audStandingBookService.exportBscBook(condition, CurrentThreadContext.getCurrentOrgCd());
			if(StringUtils.isNotEmpty(path)){
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(SysLogConstant.LOG_BK_EXPORT_SUCC);
				result.setData(path);
				BaseLogUtils.info(logger, "exportBook", "导出台账数据成功", CurrentThreadContext.getCurrentUserName());
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "exportBook", "导出台账数据失败.ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "exportBook", "导出台账数据失败,系统错误..ERROR:"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}

	/**
	 * 发送至录单员--新增评审/放款录单台账
	 */
	@RequestMapping(value = "/sendToRecoder.do", method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public DataResultVO sendToRecoder(HttpServletRequest request) throws BaseException{
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		BaseLogUtils.newLogger("发送至录单员").info();
		//项目ID
		String prjId = request.getParameter("prjId");
		//项目支付表ID
		String payId = request.getParameter("payId");
		if (StringUtils.isEmpty(prjId) && StringUtils.isEmpty(payId)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		//台账类型
		String bookTypeCd = request.getParameter("bookTypeCd");
		//放款类型
		String payTypCd = request.getParameter("payTypCd");
		//流程key
		String procDefKey = request.getParameter("procDefKey");

		String key = null;
		try {
			if (StringUtils.isEmpty(bookTypeCd)) {
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "台账类型不能为空");
			}
			//判断是否发送过,已发送过的给出提示
			AudStandingBookListRequest audRequest = new AudStandingBookListRequest();
			AuditStandingBookQueryCondition condition = new AuditStandingBookQueryCondition();
			if (StringUtils.isNotEmpty(prjId)) {
				condition.setProjectId(Long.valueOf(prjId));
			}
			if (StringUtils.isNotEmpty(payId)) {
				condition.setPayId(Long.valueOf(payId));
			}
			condition.setBookTypeCd(bookTypeCd);
			audRequest.setCondition(condition);
			audRequest.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			audRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
			ResponseData<List<AuditStandingBookDTO>> listResponseData = auditStandingBookService.searchList(audRequest);
			//不为空即发送过
			if (ResponseData.SUCCESS_CODE.equals(listResponseData.getCode())) {
				List<AuditStandingBookDTO> audResponseData = listResponseData.getData();
				if (CollectionUtils.isNotEmpty(audResponseData)) {
					throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "此单已发送至录单员，请勿重复操作！");
				}
			}

			AddAudStandingBookRequest addRequest = new AddAudStandingBookRequest();
			AuditStandingBookDTO dto = new AuditStandingBookDTO();
			if (StringUtils.isNotEmpty(prjId)) {
				dto.setProjectId(Long.valueOf(prjId));
			}
			if (StringUtils.isNotEmpty(payId)) {
				dto.setPayId(Long.valueOf(payId));
			}
			dto.setBookTypeCd(bookTypeCd);
			dto.setPayTypCd(payTypCd);
			dto.setProcDefKey(procDefKey);
			//发送时间
			dto.setCrtTm(new Date());
			dto.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			//领取状态
			dto.setReceiveState(AuditConstans.ReceiveStateEnum.RECEIVE_STATE_DLQ.key());
			addRequest.setDto(dto);
			addRequest.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			addRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
			BaseLogUtils.newLogger("发送至录单员.request:" + JSONObject.toJSONString(addRequest)).info();

			if (bookTypeCd.equals(AuditConstans.AudTypeCdEnum.AUD_TYP_CD_PL.key())){
				key = "sendToRecoder"+prjId;
			} else if (bookTypeCd.equals(AuditConstans.AudTypeCdEnum.AUD_TYP_CD_FL.key())){
				key = "sendToRecoder"+payId;
			}
			Boolean flag = cacheService.keyExists(key);
			BaseLogUtils.newLogger("查询缓存是否存在，key：{}，result:{}", key, flag);
			if(!flag){
				BaseLogUtils.newLogger("sendToRecoder.=发送至录单员="+key).info();
				this.cacheService.add(key, dto, CacheConstant.CACHE_OPERATION_REMOTE,60);
				BaseLogUtils.newLogger("sendToRecoder.发送至录单员缓存数据入参=dto:{}", JSON.toJSONString(dto)).info();
				ResponseData<Long> responseData = auditStandingBookService.addAudStandingBook(addRequest);
				BaseLogUtils.newLogger("发送至录单员.response:" + JSONObject.toJSONString(responseData)).info();
				if(responseData.getCode().equals(ResponseData.FAIL_CODE)){
					throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_601, "发送至录单员失败.");
				}else if (responseData.getCode().equals(ResponseData.SUCCESS_CODE)) {
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					result.setInfo("发送至录单员成功！");
					//金诚大客户业务领取状态变更
					if (AuditConstans.AudTypeCdEnum.AUD_TYP_CD_PL.key().equals(bookTypeCd)) {
						PrjBscInfoVO prjBscInfoVO = prjBscInfoService.selectPrjBscInfoById(Long.valueOf(prjId));
						if (BaseConstant.IS_YESNO_YES_STR.equals(prjBscInfoVO.getIsBigCstWork()) && "CHL0047".equals(prjBscInfoVO.getDsCd())) {
							ResponseData response = this.prjBscInfoJcApiService.receiveJcPrjBscInfoJc(Long.valueOf(prjId));
							if (null == response || !ResultCodeEnum.SUCCESS.getCode().equals(response.getCode())) {
								throw new BaseException(BaseExceptionConstant.INTERFACE_0102, "金诚大客户业务领取状态变更异常");
							}
						}
					}
				}
			} else {
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo("处理中，请稍后查看!");
			}
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newLogger("sendToRecoder失败.[id="+prjId+"]" + ex.getMessage()).info();
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newLogger("sendToRecoder失败.[id="+prjId+"]" + ex.getMessage()).info();
		} finally {
			BaseLogUtils.newLogger("最后执行操作：{}", key).info();
			if(this.cacheService.keyExists(key)){
				BaseLogUtils.newLogger("释放锁开始key：{}", key).info();
				boolean delete = this.cacheService.delete(key, CacheConstant.CACHE_OPERATION_REMOTE);
				BaseLogUtils.newLogger("释放锁结束key：{}，result:{}", key, delete).info();
			}
		}
		return result;
	}
	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toRevRecListPage.do", method = { RequestMethod.GET })
	public ModelAndView toRevRecListPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.newServiceLogger("加载RevRecListPage列表页面.操作人:" + CurrentThreadContext.getCurrentUserName()).info();
		ModelAndView view = new ModelAndView("project/prjbscinfo/revRecListPage");
		// 项目类型
		List<KeyValueVO> projectTypeList = getKeyValueList(DictionaryConstant.CODE_PRJ_TYPE_CD);
		if(CollectionUtils.isNotEmpty(projectTypeList)) {
			for (KeyValueVO keyValueVO : projectTypeList) {
				keyValueVO.setIsHide(false);
			}
		}
		// 业务类型
		List<KeyValueVO> bizTypeList = getKeyValueList(DictionaryConstant.CODE_PRJ_BIZ_TYP_CD);
		// 项目状态
		List<KeyValueVO> prjStsList = getKeyValueList(DictionaryConstant.CODE_AUD_STS_CD);
		// 事业部
		List<KeyValueVO> orgList = searchBusinessOrgList();
		// 合同签署方式
		List<KeyValueVO> cntTypCdList = getKeyValueList(DictionaryConstant.CODE_CNT_TYP_CD);
		// 所属区域
		List<KeyValueVO> regionList = getKeyValueList(DictionaryConstant.CODE_REGION_CD);
		// 录单领取状态
		List<KeyValueVO> receiveStateList = getKeyValueList(AudStandingBookConstant.RECEIVE_STATE);
		String currentOrgCd = CurrentThreadContext.getCurrentOrgCd();
		if(currentOrgCd.length()>8){
			if(CollectionUtils.isNotEmpty(orgList)){
				for(KeyValueVO kv:orgList){
					if(kv.getKey().equals(currentOrgCd.substring(0, 8))){
						view.addObject("currOrg", CurrentThreadContext.getCurrentOrgCd());
						break;
					}
				}
			}
		}
		//第三方机构
		FriBaseInfoQueryCondition qc = new FriBaseInfoQueryCondition();
		qc.setInsSts(FriBaseInfoConstant.FRI_BASE_INFO_INS_STS_PASS);
		qc.setInsUseCd("2");
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		List<FriBaseInfoVO> friBaseInfoVOS = this.friBaseInfoService.searchList(qc);
		view.addObject("friBaseList", friBaseInfoVOS);
		view.addObject("cntTypCdList", cntTypCdList);
		view.addObject("orgListList", orgList);
		view.addObject("projectTypeList", JSON.toJSONString(projectTypeList));
		view.addObject("bizTypeList", bizTypeList);
		view.addObject("prjStsList", prjStsList);
		view.addObject("regionList", regionList);
		view.addObject("receiveStateList",receiveStateList);
		view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
		view.addObject("currentUsrId", CurrentThreadContext.getCurrentUserId());
		return view;
	}

	/**
	 * 评审录单管理列表
	 */
	@RequestMapping(value = "/initRevRecList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initRevRecList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String everyPage = request.getParameter("pagesize");
		String prjNm = request.getParameter("prjNm");
		String cstNm = request.getParameter("cstNm");
		String crtUsrNm = request.getParameter("crtUsrNm");
		String prjTypCds = request.getParameter("prjTypCd");
		String bizTypCd = request.getParameter("bizTypCd");
		String prjStsCd = request.getParameter("prjStsCd");
		String buOrgCd = request.getParameter("buOrgCd");// 事业部
		String cstId = request.getParameter("cstId");// 客户ID
		String lsCntNo = request.getParameter("lsCntNo");
		String cstMgrNm = request.getParameter("cstMgrNm");// 客户经理
		String cntTypCd = request.getParameter("cntTypCd");
		String isDel = request.getParameter("isDel");//是否删除
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");
		String userNm = request.getParameter("userNm");
		String cstMgrId = request.getParameter("cstMgrId");
		String insCode = request.getParameter("insCode");
		String fundRasInsId = request.getParameter("fundRasInsId");
		String stDt = request.getParameter("stDt");
		String endDt = request.getParameter("endDt");
		String isSplMfr = request.getParameter("isSplMfr");
		String isInsBiz = request.getParameter("isInsBiz");
		String bookTypCd = request.getParameter("bookTypeCd");
		String receiveState = request.getParameter("receiveState");

		AudStaBookForPrjQueryCondition condition = new AudStaBookForPrjQueryCondition();
		if (StringUtils.isNotEmpty(isSplMfr)) {
			condition.setIsSplMfr(Long.valueOf(isSplMfr));
		}
		if (StringUtils.isNotEmpty(bookTypCd)) {
			condition.setBookTypeCd(bookTypCd);
		}
        if (StringUtils.isNotEmpty(receiveState)) {
            condition.setReceiveState(receiveState);
        }
		if (StringUtils.isNotEmpty(cstId)) {
			condition.setCstId(Long.valueOf(cstId));
		}
		if(StringUtils.isNotBlank(stDt)){
			condition.setStDt(DateUtils.formatStringToDate(stDt, DateUtils.YYYY_MM_DD));
		}
		if(StringUtils.isNotBlank(endDt)){
			condition.setEndDt(DateUtils.formatStringToDate(endDt, DateUtils.YYYY_MM_DD));
		}
		if(StringUtils.isNotBlank(fundRasInsId)){
			condition.setFundRasInsId(Long.valueOf(fundRasInsId));
		}
		if(StringUtils.isNotBlank(insCode)){
			condition.setInsCode(insCode);
		}
		if (StringUtils.isNotBlank(cstMgrOrgCd)) {
			condition.setCstMgrOrgCd(cstMgrOrgCd);
		}
		if (StringUtils.isNotBlank(buOrgCd)) {
			condition.setBuOrgCd(buOrgCd);
		}
		if(StringUtils.isNotBlank(isDel)){
			condition.setIsDel(Integer.valueOf(isDel));
		}
		if (StringUtils.isNotBlank(lsCntNo)) {
			condition.setLsCntNo(lsCntNo);
		}
		if (StringUtils.isNotBlank(cntTypCd)) {
			condition.setCntTypCd(cntTypCd);
		}
		if (StringUtils.isNotBlank(cstMgrNm)) {
			condition.setCstMgrNm(cstMgrNm);
		}
		if (StringUtils.isNotBlank(prjNm)) {
			condition.setPrjNm(prjNm);
		}
		if (StringUtils.isNotBlank(cstNm)) {
			condition.setCstNm(cstNm);
		}
		if (StringUtils.isNotBlank(crtUsrNm)) {
			condition.setCrtUsrNm(crtUsrNm);
		}
		if (StringUtils.isNotEmpty(prjTypCds)) {
			List<String> prjTypCdList = Arrays.asList(prjTypCds.split(";"));
			condition.setPrjTypCdList(prjTypCdList);
		}
		if (StringUtils.isNotBlank(bizTypCd)) {
			condition.setBizTypCd(bizTypCd);
		}
		if (StringUtils.isNotBlank(prjStsCd)) {
			if (prjStsCd.equals(FlowConstant.FLOW_CHECK_STATE_NON)) {
				condition.setDefPrjStsCd(prjStsCd);
			} else {
				condition.setPrjStsCd(prjStsCd);
			}
			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
		}
		if (StringUtils.isNotEmpty(userNm)) {
			condition.setUserNm(userNm);
		}
		condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
		if(StringUtils.isNotEmpty(cstMgrId)){
			condition.setCstMgrId(Long.valueOf(cstMgrId));
		}
		if (StringUtils.isNotEmpty(isInsBiz)) {
			condition.setIsInsBiz(Integer.valueOf(isInsBiz));
		}
		RevRecListRequest rev = new RevRecListRequest();
		rev.setCondition(condition);
		rev.setSysCd(CurrentThreadContext.getCurrentSysCd());
		rev.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		rev.setPageNum(Integer.valueOf(currentPage));
		rev.setPageSize(Integer.valueOf(everyPage));
		BaseLogUtils.newLogger("评审录单列表：" + JSONObject.toJSONString(rev)).info();
		ResponseData data = auditStandingBookService.selectRevRecListPage(rev);
		BaseLogUtils.newLogger("评审录单列表.response：" + JSONObject.toJSONString(data)).info();
		PageResponse<RevRecDTO> pageResponse = null;
		ListPageVO<RevRecVO> listPage = null;
		if (data.getCode().equals(ResponseData.SUCCESS_CODE)) {
			pageResponse = (PageResponse<RevRecDTO>) data.getData();
			List<RevRecDTO> list = pageResponse.getList();
			List<RevRecVO> voList = setDictionaryOption(list, "11000", "0000");
			listPage = new ListPageVO<RevRecVO>(voList, pageResponse.getTotalCount());
		}
		BaseLogUtils.newLogger("评审录单列表.response:" + listPage.getTotal());
		return listPage;
	}

	//字典选项
	private List<RevRecVO> setDictionaryOption(List<RevRecDTO> list, String sysCd, String orgCd) {
		//项目状态
		Map<String, String> prjStsMap = sysDictionaryApiService.searchGroupToMap(sysCd, orgCd, DictionaryConstant.CODE_AUD_STS_CD);
		List<Long> idList = new ArrayList<Long>();
		Map<Long, SysFlowSHDTO> flowMap = new HashMap<Long, SysFlowSHDTO>();
		List<RevRecVO> voList = new ArrayList<>();
		if (CollectionUtils.isNotEmpty(list)) {
			list.forEach(dto -> {
				idList.add(dto.getPrjId());
				RevRecVO revRecVO = new RevRecVO();
				BeanUtils.copyProperties(dto,revRecVO);
				revRecVO.setCrtUsrNm(dto.getCrtUsrName());
				voList.add(revRecVO);
			});
			//发起流程时间
			SysFlowSHQueryCondition flowQueryCondition = new SysFlowSHQueryCondition();
			flowQueryCondition.setStatus(1);//最新
			flowQueryCondition.setDataIdList(idList);
			List<String> busTypList = new ArrayList<String>();
			busTypList.add(FlowConstant.FLOW_MODEL_TYP_PRJ_1);
			busTypList.add(PrjBscInfoConstant.EXP_BIZ_FLOW);
			flowQueryCondition.setBusTypList(busTypList);
			flowQueryCondition.setWordsInTheTable(PrjBscInfoConstant.PRJ_FLOW_S_H_PRJ);
			flowQueryCondition.setSysCd(CapitalConstant.SYSCD);
			List<SysFlowSHDTO> flowSHList = this.flowQueryApiService.searchFlowSHList(flowQueryCondition);

			if (CollectionUtils.isNotEmpty(flowSHList)) {
				for (SysFlowSHDTO sysFlowSHDTO : flowSHList) {
					if (!flowMap.containsKey(sysFlowSHDTO.getDataId())) {
						flowMap.put(sysFlowSHDTO.getDataId(), sysFlowSHDTO);
					}
				}
			}
			//未发起立项流程的项目id
			List<Long> prjIds = new ArrayList<>();
			for (RevRecDTO revRecDTO : list) {
				if (!flowMap.containsKey(revRecDTO.getPrjId())) {
					prjIds.add(revRecDTO.getPrjId());
				}
			}
			if (CollectionUtils.isNotEmpty(prjIds)) {
				//查询非资管审核流程
				flowQueryCondition.setDataIdList(prjIds);
				busTypList.add(PrjBscInfoConstant.NON_INS_FLOW);
				flowQueryCondition.setBusTypList(busTypList);
				BaseLogUtils.info(logger, "setDictionaryOption", "查询非资管审核流程SysFlowSHQueryCondition=" + flowQueryCondition);
				List<SysFlowSHDTO> nonInsFlowSHList = this.flowQueryApiService.searchFlowSHList(flowQueryCondition);
				BaseLogUtils.info(logger, "setDictionaryOption", "查询非资管审核流程nonInsFlowSHList=" + JSON.toJSONString(nonInsFlowSHList));
				if (CollectionUtils.isNotEmpty(nonInsFlowSHList)) {
					for (SysFlowSHDTO sysFlowSHDTO : nonInsFlowSHList) {
						if (!flowMap.containsKey(sysFlowSHDTO.getDataId())) {
							flowMap.put(sysFlowSHDTO.getDataId(), sysFlowSHDTO);
						}
					}
				}
			}

			for (RevRecVO revRecVO : voList) {
				if (null != flowMap && flowMap.containsKey(revRecVO.getPrjId())) {
					SysFlowSHDTO sysFlowSHDTO = flowMap.get(revRecVO.getPrjId());
					//"066" 非资管审核流程 审核通过 审核不通过 设置项目状态为待提交
					if (Objects.equals(sysFlowSHDTO.getBusTyp(), PrjBscInfoConstant.NON_INS_FLOW) &&
							(Objects.equals(sysFlowSHDTO.getAudStsCd(), FlowConstant.FLOW_CHECK_STATE_PASS) || (Objects.equals(sysFlowSHDTO.getAudStsCd(), FlowConstant.FLOW_CHECK_STATE_NO_PASS)))) {
						revRecVO.setPrjStsCd(FlowConstant.FLOW_CHECK_STATE_NON);
						revRecVO.setPrjStsCdNm(prjStsMap.get(revRecVO.getPrjStsCd()));
					} else {
						if (Objects.equals(sysFlowSHDTO.getBusTyp(), PrjBscInfoConstant.EXP_BIZ_FLOW)) {
							revRecVO.setPrjStsCd(FlowConstant.FLOW_CHECK_STATE_NON);
						} else {
							revRecVO.setPrjStsCd(sysFlowSHDTO.getAudStsCd());
						}
						if (prjStsMap.containsKey(revRecVO.getPrjStsCd())) {
							revRecVO.setPrjStsCdNm(prjStsMap.get(revRecVO.getPrjStsCd()));
						}
					}
				}
				if (null == revRecVO.getPrjStsCd() || revRecVO.getPrjStsCd().equals(FlowConstant.FLOW_CHECK_STATE_NON)) {
					revRecVO.setPrjStsCd(FlowConstant.FLOW_CHECK_STATE_NON);
					revRecVO.setPrjStsCdNm(prjStsMap.get(revRecVO.getPrjStsCd()));
				}
			}
		}
		return voList;
	}

	private List<KeyValueVO> getKeyValueList(String code) throws BaseException {
		List<KeyValueVO> keyValueList = null;
		List<SysDictionaryDTO> dictionaryList = this.sysDictionaryApiService
				.searchGroup(CurrentThreadContext.getCurrentSysCd(),
						CurrentThreadContext.getCurrentOrgCd(), code);
		if (CollectionUtils.isNotEmpty(dictionaryList)) {
			keyValueList = new ArrayList<>();
			for (SysDictionaryDTO sysDictionaryDTO : dictionaryList) {
				KeyValueVO keyValue = new KeyValueVO();
				keyValue.setKey(sysDictionaryDTO.getCode());
				keyValue.setValue(sysDictionaryDTO.getCodeNm());
				keyValueList.add(keyValue);
			}
		}
		return keyValueList;
	}

	//获取事业部
	private List<KeyValueVO> searchBusinessOrgList() throws BaseException {
		List<SysOrgDTO> list = this.sysOrgApiService.searchListByOrgTypCd(CurrentThreadContext.getFlServiceSysCd());
		List<KeyValueVO> kvList = new ArrayList<KeyValueVO>();
		if (CollectionUtils.isEmpty(list)) {
			return kvList;
		}
		for (SysOrgDTO sysOrgDTO : list) {
			KeyValueVO kv = new KeyValueVO();
			kv.setKey(sysOrgDTO.getOrgCd());
			kv.setValue(sysOrgDTO.getOrgNm());
			kvList.add(kv);
		}
		return kvList;
	}

	/**
	 * 初始化列表
	 */
	@RequestMapping(value = "/initRecordBookList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initRecordBookList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		//台账类型
		String bookTypCd = request.getParameter("bookTypCd");
		//领取人
		String crtRlNm = request.getParameter("crtRlNm");
		//流程编号
		String pNo = request.getParameter("pNo");
		//承租人
		String cstNm = request.getParameter("cstNm");
		//领取日期(起)
		String crtStartDt = request.getParameter("crtStartDt");
		//领取日期(止)
		String crtEndDt = request.getParameter("crtEndDt");
		//是否厂商
		String isInsBiz = request.getParameter("isInsBiz");
		//项目类型
		String prjTypCd = request.getParameter("prjTypCd");
		//是否资管
		String isSplMfr = request.getParameter("isSplMfr");
		//放款状态
		String payStsCd = request.getParameter("payStsCd");
		//项目状态
		String prjStsCd = request.getParameter("prjStsCd");

		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		AuditStandingBookQueryCondition qc = new AuditStandingBookQueryCondition();

		if (StringUtils.isNotEmpty(bookTypCd)) {
			qc.setBookTypeCd(bookTypCd);
		}
		if (StringUtils.isNotEmpty(isInsBiz)) {
			qc.setIsInsBiz(isInsBiz);
		}
		if (StringUtils.isNotEmpty(prjTypCd)) {
			qc.setPrjTypCd(prjTypCd);
		}
		if (StringUtils.isNotEmpty(isSplMfr)) {
			qc.setIsSplMfr(isSplMfr);
		}
		if (StringUtils.isNotEmpty(crtRlNm)) {
			qc.setCrtRlNm(crtRlNm);
		}
		if (StringUtils.isNotEmpty(pNo)) {
			qc.setPNo(pNo);
		}
		if (StringUtils.isNotEmpty(pNo)) {
			qc.setPNo(pNo);
		}
		if (StringUtils.isNotEmpty(cstNm)) {
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(payStsCd)) {
			qc.setPayStsCd(payStsCd);
		}
		if (StringUtils.isNotEmpty(crtStartDt)) {
			qc.setCrtStartDt(DateUtils.formatStringToDate(crtStartDt, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotBlank(prjStsCd)) {
			if (prjStsCd.equals(FlowConstant.FLOW_CHECK_STATE_NON)) {
				qc.setDefPrjStsCd(prjStsCd);
			} else {
				qc.setPrjStsCd(prjStsCd);
			}
			qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		}
		if (StringUtils.isNotEmpty(crtEndDt)) {
			Date date = DateUtils.formatStringToDate(crtEndDt, DateUtils.YYYY_MM_DD);
			Calendar cal = Calendar.getInstance();
			cal.setTime(date);
			cal.add(Calendar.DATE, 1);
			qc.setCrtEndDt(DateUtils.formatDate(cal.getTime(), DateUtils.YYYY_MM_DD));
		}
		//承租人，流程编号全量查询
		if (StringUtils.isEmpty(cstNm) && StringUtils.isEmpty(pNo) && StringUtils.isEmpty(crtStartDt)){
			//先判断
			Calendar instance = Calendar.getInstance();
			instance.setTime(new Date());
			instance.add(Calendar.YEAR, -1);
			qc.setCrtStartDt(DateUtils.formatDate(instance.getTime(), DateUtils.YYYY_MM_DD));
		}
		if (AudStandingBookConstant.AUD_TYP_CD_FL.equals(bookTypCd) || AudStandingBookConstant.AUD_TYP_CD_PL.equals(bookTypCd)) {
			List<String> receiveStateList = new ArrayList<>();
			receiveStateList.add("2");
			receiveStateList.add("3");
			qc.setReceiveStateList(receiveStateList);
		}
		page.setCondition(qc);
		Pager pager = this.audStandingBookService.searchRecordBookListPage(page);
		List<AudStandingBookVO> list = (List<AudStandingBookVO>) pager.getResultList();
		ListPageVO<AudStandingBookVO> listPage = new ListPageVO<>(list, pager.getTotalCount());
		BaseLogUtils.newServiceLogger("initRecordBookList END DATA:" + JSON.toJSONString(page) + "操作人:" + CurrentThreadContext.getCurrentUserName()).info();
		return listPage;
	}

}

